package app.caihan.wanandroid.model.db.converters

import androidx.room.TypeConverter
import app.caihan.wanandroid.model.bean.Chapters
import com.blankj.utilcode.util.GsonUtils
import com.google.gson.reflect.TypeToken

/**
 *
 *
 * @author caihan
 * @date 2020/10/13
 * @e-mail 2730045482@qq.com
 * 维护者
 */
open class ChildChapterTypeConverters {

    @TypeConverter
    fun stringToChildChapters(json: String): List<Chapters.ChildChapters> {
        val type = object : TypeToken<List<Chapters.ChildChapters>>() {}.type
        return GsonUtils.fromJson(json, type)
    }

    @TypeConverter
    fun childChaptersToString(data: List<Chapters.ChildChapters>): String = GsonUtils.toJson(data)
}